home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mission to McDonaldLand
/
Mission To McDonaldLand.iso
/
calnz.dxr
/
00009_Script_AnimatedCast
< prev
next >
Wrap
Text File
|
1998-10-25
|
7KB
|
222 lines
property myChannel,myCastList,myink,myForecolor,myBackcolor,currentFrame,mytype¼
myRegPoint,MyLoc,NumberOfFrames,animationTempo,AnimstartTime,title,Objs,type,numLoops,loopCounter,¼
stopCriteria,manualChannel,startSound,endSound,PLayedEndSound,Callback,WasIrunning
--myChannel = sprite channel
--myCastlist = list of castnumbers that make up frames of animation
--myInk = ink to display sprite
--forecolor,backcolor obvious
--currentframe = currentframe being displayed
--myRegPoint ,Myloc- obvious
--Number of frames = the number of frames in the animation sequence
--Animation tempo = the delay to put inbetween frames
--AnimStarttime = time current frame was put onto screen, using ticks
--title = title for this object, used by object handlers
--Objs = the Object Handlers Object
--type = #animatedCast, used by ObjectHandlers routines for searching
--numLoops = the total number of frames to display, eg if 6 frames in the anim if you put 12
-- in as numloops it would play anim twice
--loopcounter = tmp variable used for seeing what iteration of the loop we're in
--stopCriteria = the number of loops to display, if -1 only 1st frame displayed
--ManualChannel = true if a channel was manually passed as a param
--Startsound = sound to play when opbject loaded
--endSound = sound to play when object reaches stop criteria
--playedEndSound = true if have already played end sound
on birth me,titleP,ObjsP,tempo,NumLoopsP,CastListIn,LocIn,inkIn,forecolorIn,¼
BackcolorIn,thisChannel,StartSoundP,EndSoundP,CallBackP
--start anim at 1st cast ember in list
set currentFrame = 1
set numLoops = numLoopsP
set stopCriteria = numLoops
set loopcounter = 1
set mytype = #animatedCast
set Objs = ObjsP
set myCastList = CastListIn
--preload all members used in anim
repeat with loadme in myCastList
preLoadMember member loadme
end repeat
set myInk = InkIn
set myForecolor = ForeColorIn
set myBackColor = BackcolorIn
set title = titleP
--was a manual channel allocated
if voidP(thisChannel) then
put getfreeChan(the freechan of Objs) into MyChannel
set manualChannel = FALSE
else
set myChannel = thisChannel
set manualChannel = true
end if
set myLoc = LocIn
--assign the delay
set animationTempo = tempo
--store time for first frame anim
set animStartTime = the ticks
assignPicCast(mychannel,getat(MyCastList,1),myink,myLoc,myBackColor)
--should we play a sound for starting the anim
if VoidP(startsoundP) = FALSE then
set StartSound = StartSoundP
puppetsound 1,0
puppetsound 1,startsound
end if
--should we play a sound when the anim finishes?
if VoidP(endSoundP)=FALSE then
set endSound = endSoundP
set PLayedEndSound= false
end if
--assign how many frames in this anim
set NumberOfFrames = count(MyCastlist)
--callback functionality for when movie stops running
if voidP(callbackP) = false then
set Callback = callbackP
end if
--stops stepframe from executing the callback function
if NumLoops < 0 then
set wasIRunning = false
else
set wasIrunning = true
end if
append(the actorlist,me)
return me
end birth
--show next frame of the anim, if reached end reset to first in castlist for next time
--round
on showNextFrame me
if currentFrame < NumberofFrames then
set currentFrame = currentFrame + 1
else
set currentFrame = 1
end if
set the member of sprite myChannel = getat(myCastList,CurrentFrame)
end showNextFrame
on NewCastlist me,CastListP,NumFrames
set myCastlist =[]
repeat with i in CastListP
append(myCastList,i)
preload member i
end repeat
set currentframe = 1
set NumberOfFrames = count(MyCastlist)
set stopCriteria = numframes
end
on stepFrame me
--have we reached the desired delay between frames?
if the ticks < animStartTime + animationTempo then
--no we havent
nothing
--following true if we are in loop infinatley mode
else if stopCriteria < 0 then
showNextFrame(me)
set animStartTime = the ticks
--following FALSE if we've reached the final number of TOTAl frames, including looping round
else if loopCounter<= StopCriteria then
set loopCounter = loopCounter + 1
showNextFrame(me)
set animStartTime = the ticks
else
--in here is stuff for when the animation is finished
--here we play a sound on anim finish
if (playedEndsound = False) and VoidP(endSound)=FALSE then
puppetsound 2,0
puppetsound 2,endsound
set playedEndSound = true
end if
--if there is a callback execute it
if voidP(callback)=FALSE and wasIrunning = TRUE then
set wasIRunning = FALSE
do callback
end if
end if
end stepframe
--make the anim loop between frame startframe and endframe
--reassigns the list of castmembers that make up the loop
on LoopBetween me,startFrame,Endframe
set tmpCastLoop = []
repeat with i = startframe to endframe
append(tmpCastLoop,getat(myCastList,i))
end repeat
set myCastlist =[]
repeat with i in tmpCastLoop
append(myCastList,i)
end repeat
set currentframe = 1
set NumberOfFrames = count(MyCastlist)
set stopCriteria = -1
end
on moveObjectOffScreen me
set the loc of sprite myChannel = point(-1000,-1000)
end moveObjectOffScreen
On MoveObject me,NewLoc
set myLoc =newloc
set the loc of sprite myChannel =newLoc
end
on kill me
set the loc of sprite mychannel to point(-2000,-2000)
if VoidP(startsound) = FALSE then
puppetsound 1,0
end if
if VoidP(endSound)=FALSE then
puppetsound 2,0
end if
if ManualChannel =FALSE then
releasechan(the FreeChan of Objs,MyChannel )
end if
puppetsprite myChannel,False
delfromactorlist(objs,me)
end kill
on switchOffObj me
set the loc of sprite mychannel to point(-2000,-2000)
if VoidP(startsound) = FALSE then
puppetsound 1,0
end if
if VoidP(endSound)=FALSE then
puppetsound 2,0
end if
if ManualChannel =FALSE then
releasechan(the FreeChan of Objs,MyChannel )
end if
set currentframe = 1
puppetsprite myChannel,False
delfromactorlist(objs,me)
end
on switchOnObj me
if manualChannel = FALSE then
set MyChannel to getfreeChan(the FreeChan of objs)
end if
assignPicCast(mychannel,getat(MyCastList,currentframe),myink,myLoc,myBackColor)
append(the actorlist,me)
if VoidP(startsound) = FALSE then
puppetsound 1,startsound
end if
end
on redrawObject me
assignPicCast(mychannel,getat(MyCastList,currentframe),myink,myLoc,myBackColor)
end
on enable me
append(the actorlist,me)
end
on disable me
delfromactorlist(objs,me)
end